<template>
  <el-dialog
    title="订单评价"
    :visible="$store.state.evalPaneShow"
    width="30%"
    @close="$store.commit('closeEvalPaneShow')"
  >
    <el-row>
      <el-col :span="4">
        <el-avatar
          :src="shop.sellAvatar"
          fit="cover"
          shape="square"
          :size="48"
        />
      </el-col>
      <el-col :span="16">
        <h4 class="shop-name">
          {{ shop.sellName }} <span class="el-icon-arrow-right"></span>
        </h4>
      </el-col>
      <el-col :span="4">
        <!-- <div class="annoymous-wrapper">
          <el-checkbox label="匿名评价"/>
        </div> -->
      </el-col>
    </el-row>
    <div class="shop-rate-wrapper">
      <div class="shop-package-rate" v-if="showSubRate">
        <span>味道 </span>
        <el-rate
          id="rate"
          v-model="level"
          :colors="['#99A9BF', '#F7BA2A', '#FF9900']"
          show-text
         
        />
      </div>
    </div>
    <div style="margin-top: 20px">
      <el-input
        id="evalContent"
        type="textarea"
        v-model="content"
        :autosize="{ minRows: 4, maxRows: 6 }"
        placeholder="满意你就夸一夸"
      />
    </div>
    <el-divider />

    <el-button type="primary" style="width: 100%" @click="submitEval"
      >提交评价</el-button
    >
  </el-dialog>
</template>

<script>
import shopService from "../../service/ShopService";
import orderItem from "../order/OrderItem";
export default {
  data() {
    return {
      level: 0,
      content: "",
      foodNames: [],
      shop: {},
      params:{
        level: 0,
        content:"",
        foodNames:[]
      }
    };
  },
  created() {
    this.handleInit();
  },
  methods: {
    handleInit() {
      var data = shopService.getShopInfo("1001");
      data.then((v) => {
        this.shop = v;
      });
    },
    submitEval() {
      this.foodNames = this.$store.state.foodNames
      console.log(this.foodNames);
      // 发送插入评价记录的请求 评价等级，评价内容
      this.params.foodNames = this.foodNames
      // console.log( this.params.foodNames)
      // console.log(JSON.parse(JSON.stringify(this.params.foodNames)))
  
      this.params.level = this.level;
      this.params.content = this.content
      // shopService.addEval(this.params)
      // this.$notify({
      //   title: '成功',
      //   message: '提交评价成功',
      //   type: 'success'
      // })
     
      // 关闭对话框
      this.$store.commit("closeEvalPaneShow");
      // 重置输入框的值
      this.level=0
      this.content=''
      this.$store.state.foodNames= []
    },
  },
  computed: {
    showSubRate() {
      return this.mainRate !== 0;
    },
  },
};
</script>

<style lang="less" scoped>
.shop-name {
  margin: 0;
  padding: 0;
  vertical-align: middle;
  font-size: 16px;
  height: 48px;
  font-weight: 550;
  line-height: 48px;
  cursor: pointer;
}
.annoymous-wrapper {
  height: 48px;
  line-height: 48px;
}
.shop-rate-wrapper {
  text-align: center;
}
.shop-main-rate /deep/ .el-rate__icon {
  font-size: 32px;
}
.shop-package-rate {
  margin-top: 20px;
  /deep/ .el-rate__icon {
    font-size: 26px;
  }
  .el-rate {
    display: inline-block;
  }
}
.upload {
  margin-top: 20px;
}
.fengniao-delivery {
  background-color: #409eff;
  color: white;
  font-weight: 400;
  margin-left: 10px;
  font-size: 12px;
  padding: 2px;
  border-radius: 5px;
}
.rider-eval-list {
  display: flex;
  justify-content: space-around;
  .rider-eval-item {
    flex: 0 0 33.33%;
    text-align: center;
  }
  .rider-eval-icon {
    font-size: 36px;
    color: #ccc;
    cursor: pointer;
    transition: all 0.2s;
  }
  .rider-eval-icon:hover {
    color: #e6a23c;
  }
  .active {
    color: #e6a23c;
  }
}
</style>
